home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
130 MIDI Tool Box
/
130 MIDI Tool Box.iso
/
dac12x16
/
ftocga.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-09-15
|
516b
|
22 lines
/* ftocga--float to cga 640 x 200 plot
* ftocga < infile > outfile
* where infile wave ranges between +- 1 and outfile is 0 to 199
*/
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define CGASCALE 99.5
main()
{
float x;
short y;
setmode(fileno(stdin), O_BINARY);
setmode(fileno(stdout), O_BINARY);
while (fread((char *)&x, sizeof(float), 1, stdin))
{
y = x * CGASCALE+CGASCALE;
fwrite((char *)&y, sizeof(short), 1, stdout);
}
}